<?php
session_start();
include '../connect.php';
include '../functions.inc';

$sql = ("SELECT user_id FROM $table_name WHERE user_name='".mysql_real_escape_string($_SESSION['logname'])."'");
$result = mysql_query($sql,$db);
$user_id = mysql_fetch_array($result);

$sql = ("DELETE FROM exppro WHERE user_id='".mysql_real_escape_string($user_id[0])."'");
mysql_query($sql,$db);

	for ( $i=1; $i < 5; $i++ )
	{ 
		if ( $_POST["titre_$i"] != "" )
		{
			$dtstart = $_POST["dtstart_$i"];
			$dtend = $_POST["dtend_$i"];
			$summary = $_POST["summary_$i"];
			$titre = $_POST["titre_$i"];
			$employeur = $_POST["employeur_$i"];
			$location = $_POST["location_$i"];

			$sql = ("INSERT INTO exppro VALUES('', 
			'".mysql_real_escape_string($user_id[0])."', 
			'".mysql_real_escape_string($employeur)."', 
			'".mysql_real_escape_string($titre)."', 
			'".mysql_real_escape_string($location)."', 
			'".mysql_real_escape_string($dtstart)."',
			'".mysql_real_escape_string($dtend)."', 
			'".mysql_real_escape_string($summary)."')");

			// updateDateUser($_SESSION['logname'],$table_name);
			mysql_query($sql) or die(mysql_error());

		}
	}

?>